package TransactionImplementation

import (
	"SalaryPayment/DataBase"
	"SalaryPayment/ModelImplementation"
	"reflect"
	"time"
)

type ServiceChargeTransaction struct {
	itsDate     time.Time
	itsCharge   float64
	itsMemberId int
}

func (sct *ServiceChargeTransaction) Execute() {
	e := DataBase.PayrollDatabase.GetUnionMember(sct.itsMemberId)

	af := e.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation{}) {
		uaf := af.(*ModelImplementation.UnionAffiliation)
		uaf.AddServiceCharge(sct.itsDate, sct.itsCharge)
	}
}
